<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <script>
        window.onload=function(){
            //全局注册指令
            Vue.directive('myfocus',{
                bind(el,binding,vnode,oldvnode){
                    // console.log(el)
                },
                inserted(el){
                    el.focus();
                },
                update(){
                    alert();
                }
            })
            new Vue({
                el:'#app',
                data:{
                    str:'tom'
                },
                methods:{}
            })
        }
    </script>
</head>
<body>
    <div id="app">
        <input type="text" v-model='str' v-myfocus>
    </div>
</body>
</html>